import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import FormAddImage from '../../components/formAddImage';

class _ImageAdd extends React.Component{
    constructor(props){
        super(props);
        this.state= {
            user: this.props.user,
            patients: this.props.patients
        }
    }
    componentWillReceiveProps(next){
        this.setState({
            user: next.user,
            patients: next.patients
        })
    }
    static contextTypes = {
        router: React.PropTypes.object
    };
    render(){
        return(
            <div id="image-add">
                <FormAddImage
                    user={this.state.user}
                    patients={this.props.patients}
                    _r = {this.context.router}
                    onSub={this.onSub}
                    isModal={this.props.isModal}
                    dispatch={this.props.dispatch}
                />
            </div>
        )
    }
}
const ImageAdd = connect((state)=>{
    "use strict";
    const {user,patients} = state.rootReducer;
    return {user,patients}
})(_ImageAdd);
export default ImageAdd
